<?php
/**
 * Template Name: Venues
 */
get_header(); ?>

<div class="container">
    <? while (have_posts()) : the_post(); ?>

    <?
    $custom = get_fields($post->ID);
    $currentID = $post->ID;
    //var_dump($fields);
    ?>

    <div>
        <h1><? the_title() ?></h1>

        <div class="row-fluid">
            <div class="span12">
                <div class="card grey" style="display: block;">
                    <div class="card-image" style="margin-bottom: 0">
                        <div id="map_canvas" style="width: 100%; height: 600px"></div>
                    </div>
                </div>
            </div>
            <div class="span7" style="display: none">
                <?
                $venue_query = new WP_Query(array('post_type' => 'venue', 'showposts' => 100));
                while ($venue_query->have_posts()) : $venue_query->the_post();

                    $venueFields = get_fields($venue_query->post->ID);
                    ?>

                    <div class="card grey search-result clearfix" style="display: block;">
                        <a href="<? echo get_permalink($venue_query->post->ID) ?>" class="btn btn-small btn-primary pull-right" style="margin-top:-5px;margin-bottom:-15px;clear:both"><span style="font-weight: 800">View »</span></a>

                        <h3 style=" margin-bottom: 5px;">
                            <a href="<? echo get_permalink($venue_query->post->ID) ?>" class="result-title"> <? echo $venueFields['name']; ?> </a>
                        </h3>

                        <a href="<? echo get_permalink($venue_query->post->ID) ?>"
                           style="width:190px;display: block;float: left;margin-bottom: -10px;">
                            <? printImage($venueFields['image_1'], $venueFields['name'], 'pitch-main') ?>
                        </a>

                        <table class="table table-striped table-condensed table-bordered" style="width: 330px;float: right;margin-bottom:0;">
                            <tbody>
                            <!--<tr>
                                <td><strong>Address</strong></td>
                                <td class="addresses"><? echo $venueFields['address']; ?></td>
                            </tr>-->
                            <tr>
                                <td><strong>Nearest Station(s)</strong></td>
                                <td><? echo $venueFields['nearest_station']; ?></td>
                            </tr>
                            <tr>
                                <td><strong>Changing Rooms</strong></td>
                                <td><? echo $venueFields['changing_rooms']; ?></td>
                            </tr>
                            <tr>
                                <td><strong>Showers</strong></td>
                                <td><? echo $venueFields['showers']; ?></td>
                            </tr>
                            </tbody>
                        </table>

                        <div class="addresses" data-url="<? echo get_permalink($venue_query->post->ID) ?>" data-title="<? echo $venueFields['name'] ?>" style="display: none"><? echo $venueFields['address']; ?></div>

                    </div>

                    <?
                endwhile;
                ?>

            </div>
        </div>


    </div>

    <? endwhile; ?>
</div>

<?php get_footer(); ?>

<script type="text/javascript"
        src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB-k-7b00P-IEkcvnNmQekON1RL9SVPSQI&sensor=false"></script>
<script src="<?php echo get_template_directory_uri(); ?>/js/PITCHWISE.multiMap.js"></script>

<script>
    $(function () {
        var options = {};
        var geoMap = new PITCHWISE.multiMap(options);


        PW.pitch.init();
    });
</script>